﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Manage
{
    public delegate void F();
    public partial class Login : Form
    {
        public event F GetAllKey;
        public Login()
        {
            InitializeComponent();
        }
      
        private void btLogin_Click(object sender, EventArgs e)
        {
            if (tbLoginUserName.Text.Trim() == "" || tbLoginPassword.Text == "")
            {
                MessageBox.Show("帐号、密码不能为空！");
                return;
            }
            Dictionary<string, string> msg = ThisLink.cRequst.MLogin(tbLoginUserName.Text, tbLoginPassword.Text);
            if (msg["status"] == "")
            {
                GetAllKey();
                this.Close();
            }
            else
            {
                MessageBox.Show(msg["message"]);
            }
        }

        private void btExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void tbLoginPassword_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode==Keys.Enter)
            {
                btLogin_Click(sender, e);
            }
        }
    }
}
